package com.jeesite.modules.recovery.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * @描述: 操作员类型 . <br/>
 * 适用于表：
 * TBL_BOSS_OPERATOR， 
 * TBL_MERCHANT_OPERATOR .
 * 
 * @作者: WuShuicheng .
 * @创建时间: 2013-9-12,上午11:16:23 .
 * @版本: 1.0 .
 */
public enum CustomerType {

	/** 普通用户 **/
	SF("物流（快递）问题", "1"),
	/** 超级管理员 **/
	HTKY("收到货后发现包裹/产品外包装破损", "2"),
	ZTO("快递派件延误，快递员不给派件、查件", "3"),
	STO("产品漏发少发（责任在快递方）", "4"),
	YTO("丢件", "5"),
	YD("其他", "6");
	
	

	/** 描述 */
	private String name;
	/** 枚举值 */
	private String value;

	private CustomerType(String name, String value) {
		this.name = name;
		this.value = value;
	}
	

	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getValue() {
		return value;
	}


	public void setValue(String value) {
		this.value = value;
	}


	public static CustomerType getEnum(String value){
		CustomerType resultEnum = null;
		CustomerType[] enumAry = CustomerType.values();
		for(int i = 0;i<enumAry.length;i++){
			if(enumAry[i].getValue().equals(value)){
				resultEnum = enumAry[i];
				break;
			}
		}
		return resultEnum;
	}
	
	public static Map<String, Map<String, Object>> toMap() {
		CustomerType[] ary = CustomerType.values();
		Map<String, Map<String, Object>> enumMap = new HashMap<String, Map<String, Object>>();
		for (int num = 0; num < ary.length; num++) {
			Map<String, Object> map = new HashMap<String, Object>();
			String key = String.valueOf(getEnum(ary[num].getValue()));
			map.put("value", ary[num].getValue());
			map.put("name", ary[num].getName());
			enumMap.put(key, map);
		}
		return enumMap;
	}
	
	
	public static List toList(){
		CustomerType[] ary = CustomerType.values();
		List list = new ArrayList();
		for(int i=0;i<ary.length;i++){
			Map<String,String> map = new HashMap<String,String>();
			map.put("value",ary[i].getValue());
			map.put("name", ary[i].getName());
			list.add(map);
		}
		return list;
	}
	
	public static String getKey(String value){
		CustomerType[] ary = CustomerType.values();
		String result="";
		for(int i=0;i<ary.length;i++){
			

			if(value.equals(ary[i].getValue())){
				result=ary[i].getName();
				break;
			}
		
		}
		return result;
	}
	
	public static void main(String[] args) {
		
		System.out.println(CustomerType.getKey("1"));
	}

}

